/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.core.domain.account;

import info.peigen.hotpot.business.account.facade.enums.AccountFreezeDirection;
import info.peigen.hotpot.business.account.facade.enums.AccountFreezeType;
import info.peigen.hotpot.common.core.domain.DomainObject;
import info.peigen.hotpot.common.core.lang.money.Money;
import jakarta.validation.constraints.NotEmpty;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

/**
 * <b>(AccountFreezeLog)</b>
 * 账户冻结记录
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/10
 */
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class AccountFreezeLog extends DomainObject {
    /** 账户号 */
    @NotEmpty
    String accountId;
    /** 交易ID */
    String                 tradeId;
    /** 冻结类型 */
    AccountFreezeType      freezeType;
    /** 冻结金额 */
    Money                  freezeAmount;
    /** 冻结方向 */
    AccountFreezeDirection direction;
    /** 描述 */
    String                 reason;
    /** BOPS操作员 */
    String                 bopsOperatorId;

    public static AccountFreezeLog withdrawFreeze(Account account, Money freezeAmount, AccountFreezeType freezeType, String tradeId, String reason) {
        return AccountFreezeLog.builder()
                .accountId(account.getAccountId())
                .tradeId(tradeId)
                .freezeType(freezeType)
                .tradeId(tradeId)
                .freezeAmount(freezeAmount)
                .direction(AccountFreezeDirection.Freeze)
                .reason(reason)
                .build();
    }


    public static AccountFreezeLog withdrawUnfreeze(Account account, Money freezeAmount, AccountFreezeType freezeType, String tradeId, String reason) {
        return AccountFreezeLog.builder()
                .accountId(account.getAccountId())
                .tradeId(tradeId)
                .freezeType(freezeType)
                .tradeId(tradeId)
                .freezeAmount(freezeAmount)
                .direction(AccountFreezeDirection.Unfreeze)
                .reason(reason)
                .build();
    }
}
